Updated: Aug 2, 2024—2 min read

Using Telegram as Cloud Camera Storage with Home Assistant

Written by: Fixt

Create a bot

First, you need to messaje @BotFather here.

/newbot

Get User ID

You can get the id of your account or group by sending the message /start to the @GetIdsBot here.

Configuration

You can find the documentation here.

config/configuration.yaml

telegram_bot:
  - platform: polling
    api_key: "your bot key"
    allowed_chat_ids:
      - 44441111
 
notify:
  - platform: telegram
    name: "Fixt"
    chat_id: 44441111
 
homeassistant:
  allowlist_external_dirs:
    - /tmp

Folder Watcher

Documentation

Open your Home Assistant instance and start setting up a new integration.
Folder Watcher Integration

Automation Examples

Part 1

Trigger Video Recording

alias: Door notification
description: ""
trigger:
  - entity_id: binary_sensor.entrance_door
    from: 'off'
    platform: state
    to: 'on'
action:
  - data:
      message: Front Door Open
    service: telegram_bot.send_message
  - data:
      duration: 15
      entity_id: camera.entrance
      filename: /tmp/entrance_{{ as_timestamp(now()) | int }}.mp4
    service: camera.record
mode: single

Part 2

Send video after recording is finished

alias: Send Recorded Entrance Video
description: ""
trigger:
  - platform: event
    event_type: folder_watcher
    event_data:
      event_type: closed
condition:
  - condition: template
    value_template: "{{ trigger.event.data.file.startswith('entrance_') }}"
action:
  - service: notify.fixt
    data_template:
      message: ""
      data:
        video:
          file: "{{ trigger.event.data.path }}"
          caption: "{{\"\\U0001F3C3\"}} Entrance Video"
mode: single

I would love to hear your comments, or suggestions on this post.


Avatar of Fixt

Fixt is a Software Engineer passionate about making the world a better place through technology and automation.